<html>
<head>
  <meta charset="UTF-8">
  <title>videocontroller</title>
</head>
<body>
  <?php 
  require 'Controller.php';
  require 'Admin/Model/VideoModel.php';
  
  class VideoController extends Controller{
  
    function __construct(){
      parent::__construct();
    }
    function listvideo(){
      /*data=array(array('uname'=>'zhangsan','sex'=>'male'),array('uname'=>'lisi','sex'=>'female'));*/
      $model=new VideoModel();
      $data=$model->getVideoList();

      $this->assign('video',$data);
      $this->display();
      /*return $data;
*/    }
      
      function delVideo(){
        $vid=$_GET['vid'];
        $model=new VideoModel();
        $result=$model->delVideo($vid);
        if($result){
          echo "删除成功！三秒后就跳转用户列表页";
          header("refresh:3;url='admin.php?c=video&m=listvideo'");
        }
        else{
          echo "删除失败！三秒后就跳转用户列表页";
          header("refresh:3;url='admin.php?c=video&m=listvideo'");
        }


}

      function regvideo(){
        $this->display();
      }
      function addvideo(){
        $data=$_POST;
      /*  var_dump($data);*/
        $file=$_FILES;
        $model=new VideoModel();
        $result=$model->addvideo($data,$file);
        if ($result) {
          echo "注册成功,3秒后返回用户列表页";
         header("refresh:3;url='admin.php?c=video&m=listvideo'");
        }else{
          echo "注册失败,3秒后返回注册也重新注册";
          header("refresh:3;url='admin.php?c=video&m=listvideo'");
        }
      }
    
    function editvideo(){
        $vid=$_GET['vid'];
        $model=new VideoModel();
        $data=$model->editvideo($vid);
        $this->assign('video',$data);
          $this->display();
      }
     

 function updatevideo(){
        $data=$_POST;
        $file=$_FILES;
        $model=new VideoModel();
        $result=$model->updatevideo($data,$file);
        if($result){
          echo "修改成功！三秒后就跳转用户列表页";
          header("refresh:3;url='admin.php?c=video&m=listvideo'");
        }
        else{
          echo "修改失败！三秒后就跳转用户列表页";
          header("refresh:3;url='admin.php?c=video&m=listvideo'");
        }
      }


  }

   ?>
</body>
</html>
